feat(UI): update Axum router to OpenApiRouter for swagger generate#1046
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Pull Request Overview
This PR replaces manual Axum routers with OpenApiRouter to generate Swagger documentation and updates the TypeScript client to call new Git-related endpoints.
- Switch core and gateway server routers to use
utoipa_axum::OpenApiRouterand serve Swagger UI - Add OpenAPI annotations (
IntoParams,ToSchema) andApiDocstructs for auto-generated docs - Extend the TS client (
generated.ts) with types and methods for blob, file creation, commit, tree, and clone-check APIs
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| moon/packages/types/generated.ts | Added new result types and client methods for Git endpoints |
| mono/src/server/https_server.rs | Switched to OpenApiRouter, integrated Swagger UI, defined ApiDoc |
| mono/src/api//_router.rs | Migrated all sub-routers to OpenApiRouter |
| mono/src/api/api_router.rs | Refactored main API router to use routes! and OpenAPI annotations |
| mono/Cargo.toml | Added utoipa-axum and utoipa-swagger-ui dependencies |
| gateway/src/https_server.rs | Integrated OpenApiRouter and updated mega_routers |
| gateway/src/api/github_router.rs | Migrated GitHub webhook router to OpenApiRouter |
| gateway/Cargo.toml | Added utoipa-axum and Swagger UI deps |
| ceres/src/model/git.rs | Derive IntoParams/ToSchema for OpenAPI schema and params |
| Cargo.toml (root) | Added utoipa-axum and utoipa-swagger-ui versions |
| .github/workflows/base.yml | Corrected workflow path glob to .github/workflows/web-test* |
Comments suppressed due to low confidence (2)
moon/packages/types/generated.ts:3042
- The type
CommonResultVecTreeBriefItemis missing theerr_messageproperty, which is present in similar result types; adderr_message: stringfor consistency.
export type CommonResultVecTreeBriefItem = {
moon/packages/types/generated.ts:12586
- The
create-fileendpoint is defined as GET but performs a side-effect and accepts a request body; consider changing this to POST for correct HTTP semantics.
* @request GET:/api/v1/create-file
There was a problem hiding this comment.
Pull Request Overview
This PR migrates existing Axum routers to OpenApiRouter to enable automatic Swagger/OpenAPI generation across services.
- Replaced
RouterwithOpenApiRouterin all endpoint modules and updated route annotations. - Integrated
utoipaderive macros andSwaggerUisetup in HTTPS servers for both mono and gateway. - Added corresponding TypeScript definitions and updated Cargo.toml and workflow configurations.
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| moon/packages/types/generated.ts | Added common result & endpoint types for new Git file APIs |
| mono/src/server/https_server.rs | Switched to OpenApiRouter, exposed ApiDoc and Swagger UI |
| mono/src/api/user/user_router.rs | Migrated user routes to OpenApiRouter |
| mono/src/api/oauth/mod.rs | Migrated OAuth routes to OpenApiRouter |
| mono/src/api/mr/mr_router.rs | Migrated MR routes to OpenApiRouter |
| mono/src/api/lfs/lfs_router.rs | Migrated LFS routes to OpenApiRouter |
| mono/src/api/issue/issue_router.rs | Migrated issue routes to OpenApiRouter |
| mono/src/api/api_router.rs | Migrated aggregated API router and added #[utoipa::path] tags |
| mono/Cargo.toml | Added utoipa-axum & utoipa-swagger-ui dependencies |
| gateway/src/https_server.rs | Switched gateway to OpenApiRouter and added empty ApiDoc |
| gateway/src/api/github_router.rs | Migrated GitHub webhook to OpenApiRouter |
| gateway/Cargo.toml | Added utoipa-axum & utoipa-swagger-ui dependencies |
| docker/mono-pg-dockerfile | Removed database initialization script |
| ceres/src/model/git.rs | Derived ToSchema/IntoParams for OpenAPI support |
| Cargo.toml | Added top-level utoipa-axum & utoipa-swagger-ui versions |
| .github/workflows/base.yml | Fixed workflow path pattern for web-test files |
Comments suppressed due to low confidence (2)
docker/mono-pg-dockerfile:17
- Removing the database initialization script will prevent automatic schema setup on container startup. Ensure migrations or initialization steps are handled elsewhere or restore the copy.
COPY ./sql/postgres/pg_20241204__init.sql /docker-entrypoint-initdb.d/
mono/src/api/api_router.rs:111
- The documented response body is
LatestCommitInfobut the handler actually returnsCommonResult<LatestCommitInfo>. Update the annotation to match the wrapper type.
(status = 200, body = LatestCommitInfo, content_type = "application/json")
|
|
||
| /// Create file in web UI | ||
| #[utoipa::path( | ||
| get, |
There was a problem hiding this comment.
This endpoint uses GET but also accepts a request body (CreateFileInfo). According to HTTP semantics, GET should not have a body—consider switching to POST or another appropriate verb for creating resources.
| get, | |
| post, |
| }; | ||
| } | ||
|
|
||
| #[derive(OpenApi)] |
There was a problem hiding this comment.
[nitpick] ApiDoc is derived but no paths or tags are specified, so the generated OpenAPI document will be empty. Add a #[openapi(paths(...), tags(...))] attribute to include gateway endpoints.
| #[derive(OpenApi)] | |
| #[derive(OpenApi)] | |
| #[openapi( | |
| paths( | |
| github_router::routers, | |
| lfs_router::routers, | |
| mono::api::api_router::routers | |
| ), | |
| tags( | |
| (name = "GitHub", description = "GitHub-related endpoints"), | |
| (name = "LFS", description = "Large File Storage endpoints"), | |
| (name = "Mono", description = "Mono API endpoints") | |
| ) | |
| )] |
|
|
||
| pub fn routers() -> Router<MonoApiServiceState> { | ||
| Router::new().nest( | ||
| pub fn routers() -> OpenApiRouter<MonoApiServiceState> { |
There was a problem hiding this comment.
[nitpick] The MR routes lack OpenAPI annotations (#[utoipa::path]), so they won't appear under the merge_request tag. Add path annotations and tags for each MR endpoint.
No description provided.